from contextlib import contextmanager


class Session(object):

    @classmethod
    @contextmanager
    def temp(cls, user_id, tenant_id):
        import service

        session = Session(user_id, tenant_id)
        service.BaseService.activate_session(session)
        yield
        service.BaseService.activate_session(None)

    def __init__(self, user_id, tenant_id):
        self.user_id = user_id
        self.tenant_id = tenant_id
        return

